package com.gjy.design.single;

/**
 * @author gjy
 * @version 1.0
 * @since 2025-11-06 10:05:40
 */
public class LazySingletonThreadSafe {


    private static LazySingletonThreadSafe instance;

    private LazySingletonThreadSafe() {}

    // 给整个方法加锁，保证线程安全
    public static synchronized LazySingletonThreadSafe getInstance() {
        if (instance == null) {
            instance = new LazySingletonThreadSafe();
        }
        return instance;
    }

    public void doSomething() {
        System.out.println("懒汉式(方法同步)单例正在执行业务...");
    }

}
